package com.ludomancy.gamelib;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;

import com.ludomancy.gamelib.ResourceManager;
import com.ludomancy.gamelib.Utils;
import com.ludomancy.gamelib.Widget;

public class PictureWidget extends Widget
{
	private Image portrait;
	
	public PictureWidget(Widget parent, String imageName, int width)
	{
		super(parent, new Rectangle());
		portrait = ResourceManager.getImage(imageName);
		setRelativeRect(new Rectangle(0,0,width, portrait.getHeight(null)));
	}

	public void paint(Graphics g)
	{
		Point center = Utils.getCenterInRect(new Point(portrait.getWidth(null), portrait.getHeight(null)), getClientRect());
		g.drawImage(portrait, center.x, 0, null);
	}

}
